<?php

namespace app\api\controller;
header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept,fs-token");
header('Access-Control-Allow-Methods: GET, POST');
use think\Controller;

class Base extends Controller
{
    /**
     * api接口返回友好信息
     * @param number $code   状态
     * @param string $msg    状态描述
     * @param unknown $data  返回数据
     */
    public function apiReturn( $code=200 , $msg='', $data = array() ,$Total=0 ){
        $returnData = array(
            'code' => $code,
            'msg'  => $msg?$msg:return_msg($code),
            'data' => $data,
            'Total'=>$Total
        );
        if(I('callback')){
            echo I('callback').'('.json_encode($returnData).')';die;
        }
        echo json_encode($returnData);die;
    }
}
